﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CityLife.Resources;
using System.Windows.Media.Imaging;
using CityLife.Objects;
using CityLife.CityService;

namespace CityLife
{
	public partial class Empty : UserControl, ICityDesign
	{
		public Empty()
		{
			// Required to initialize variables
			InitializeComponent();

          //  this.MouseEnter += new MouseEventHandler(Empty_MouseEnter);
          //  this.MouseLeave += new MouseEventHandler(Empty_MouseLeave);
		}


        public void init()
        {
            Zone z = this.Parent as Zone;
            this.row.Text = "R:" + this.GetValue(Grid.RowProperty);
            this.col.Text = "C:" + this.GetValue(Grid.ColumnProperty);

        }



        void Empty_MouseLeave(object sender, MouseEventArgs e)
        {
         //   EmptyBorder.BorderBrush = new SolidColorBrush(Colors.Transparent);
         //   Cursor.Visibility = Visibility.Collapsed;
        }

        void Empty_MouseEnter(object sender, MouseEventArgs e)
        {
       //     EmptyBorder.BorderBrush = new SolidColorBrush(Colors.Yellow);
        //    Cursor.Visibility = Visibility.Visible;

//            StreamResourceInfo sr = Application.GetResourceStream(
//    new Uri("SilverlightApplication1;component/MyImage.png", UriKind.Relative));
//BitmapImage bmp = new BitmapImage();
//bmp.SetSource(sr.Stream);


            //BitmapImage bmp = new BitmapImage();
            //bmp.SetSource( ToolsImages.Residential1);

            //Cursor.Source = bmp;
            ;//       MainPage.Editor.ActiveTool
        }

        public void clearBorder()
        {
            EmptyBorder.BorderThickness = new Thickness(0, 0, 0, 0);

        }


        public void setBorder(Direction direction, bool ok)
        {

       


            if(!ok)
                EmptyBorder.BorderBrush = new SolidColorBrush(Colors.Red);
            else
                EmptyBorder.BorderBrush = new SolidColorBrush(Colors.Yellow);


            Thickness t = EmptyBorder.BorderThickness;
            if (direction == Direction.Top)
               t  = new Thickness(t.Left, 1, t.Right, t.Bottom);


            if (direction == Direction.Bottom)
                  t = new Thickness(t.Left, t.Top, t.Right, 1);
 

            if (direction == Direction.Right)
                t = new Thickness(t.Left, t.Top, 1, t.Bottom);


            if (direction == Direction.Left)
                t = new Thickness(1, t.Top, t.Right, t.Bottom);


            EmptyBorder.BorderThickness = t;



        }



        #region ICityDesign Members


        public CursorType CursorType
        {
            get { return CursorType.Single; }
        }

        public Image Thumbnail
        {
            get
            {
                Image thumbnail = new Image();
                Uri uri = new Uri(Application.Current.Host.Source.AbsoluteUri.Replace(Application.Current.Host.Source.LocalPath, "") + "/images/ToolThumbs/R1D1.png", UriKind.Absolute);
                ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
                thumbnail.SetValue(Image.SourceProperty, img);
                return thumbnail;

            }
        }

        public CityEditor.Tools ToolType
        {
            get { return CityEditor.Tools.Residential1; }
        }


        public ShopInfo Info
        {
            get
            {
                ShopInfo info = new ShopInfo();
                info.DesignType = this.GetType();
                info.Name = " A clean start";
                info.Cost = 1;
                info.BuildDuration = 30;
                info.RepairDuration = 30;
                info.MaxAge = 0;
                info.XP = 100;
                info.ElementType = CityLife.CityService.CityElementType.Empty;

                info.Thumbnail = new Uri(Application.Current.Host.Source.AbsoluteUri.Replace(Application.Current.Host.Source.LocalPath, "") + "/images/ToolThumbs/R1D1.png", UriKind.Absolute).ToString();

                return info;
            }
        }

        public void SetBuildStep(CityElementStage step)
        {

        }
        #endregion
    }
}